import { RequestHandler } from 'express';
import { set_file_uni_float } from '../../../Func/set_file_uni_float';
import { sign_cur_uni_float_identity_type_create } from '../Func/sign_cur_uni_float_identity_type_create';
import { res_send_create_uni_float } from '../Classes/cla_res_send_create_uni_float';
import { log_info_cur_user_create_uni_float } from '../Func/Log_info';
import { req_cur_user_create_uni_float_info } from '../Classes/cla_req_cur_user_create_uni_float_info';
import { get_mdb_user_uni_float_identity_type_create } from '../../../DataDefine/get_mdb';
import { prop_cur_req_user_identity } from '../../../../../../../../../Classes/cla_req_cur_headers_info';
import { sign_cur_uni_float_identity_type_active } from '../Func/sign_cur_uni_float_identity_type_active';
import { get_cur_db_count_for_id } from '../../../../../../../../../Func/get_mdb_new_id';
/**
 * 创建 一个 浮动元素
 */
export const create_uni_float: RequestHandler = async (req, res) => {
  /**
   * 当前 请求 信息
   */
  let cur_uni_float_infos = new req_cur_user_create_uni_float_info(req);

  cur_uni_float_infos.id = await get_cur_db_count_for_id(
    get_mdb_user_uni_float_identity_type_create(
      cur_uni_float_infos[prop_cur_req_user_identity]
    )
  );

  /**
   * 记录 身份 用户 的 浮动元素
   */
  sign_cur_uni_float_identity_type_create(cur_uni_float_infos);

  sign_cur_uni_float_identity_type_active(cur_uni_float_infos);

  /**
   * 记录 文件 创建信息
   */
  set_file_uni_float(cur_uni_float_infos);

  /**
   * log 用户 新创建 浮动元素
   */
  log_info_cur_user_create_uni_float(cur_uni_float_infos);

  let res_send = new res_send_create_uni_float();

  res.send(res_send);
};
